package org.soarsky.wealthchengdu.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBOpenHelper extends SQLiteOpenHelper {

	private static final String DBNAME = "witness.db";
	private static final int VERSION = 2;

	public DBOpenHelper(Context context) {
		super(context, DBNAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// 按照USER建立用户表（生成ID）OP_USER_NAME操作用户名 UserType 0登录用户 1离线用户 2开户用户/
		// IS_DELETE 用户信息是否删除 0未删除 1逻辑删除 DataStatus 0 完整 1 基本 2 未完整
		db.execSQL(" create table DATA (_id integer primary key autoincrement,idto text,"
				+ "title text,titleEn text,subTitle text,subTitleEn text,img text,"
				+ "imgEn text,source text,sourceEn text,content text,contentEn text,"
				+ "admireNum tex,remarkNum text,shareNum text,addTime text,pvNum text,collectNum text)");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// 注：生产环境上不能做删除操作
		if (newVersion > oldVersion) {
			db.execSQL("DROP TABLE IF EXISTS DATA");
			onCreate(db);
		}
	}
}
